package cn.bytecollege.admin.controller;

import cn.bytecollege.admin.service.CartService;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

@WebServlet(name = "CartClearController", value = "/admin/cartClear")
public class CartClearController extends HttpServlet {
    private CartService cartService = null;
    public CartClearController() {
        cartService = new CartService();
    }
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        cartService.clearCart();
        response.sendRedirect(request.getContextPath()+"/admin/cartList");
    }
}
